package jtk.project4.fleet.screen.addEditNewEmployee;

import java.sql.SQLException;

import nl.coderight.jazz.Controller;
import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Employee;
import jtk.project4.fleet.event.EmployeeEvent;

public class AddEditNewEmployeeController extends Controller {
	private FleetModel fleetModel;
	private AddEditNewEmployeeView employeeView;
	
	public void handleEvent(EmployeeEvent evt) throws SQLException {
		Employee employeess = fleetModel.getEmployeess();
		switch (evt.getType()) {
		case SAVE:
			//commit changes
			System.out.println("nomor :"+employeess.getCity());
			fleetModel.insertEmployees(employeess);
			//executeTask(new LoadVendorTask());
			break;
			
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		employeeView = new AddEditNewEmployeeView();
		setView(employeeView);
		showView();
	}
}
